package org.example.nio.demo;

import java.io.IOException;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;

public class NioServer1 {

    public static void main(String[] args) {
        try {
            ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();
            // 设置为非阻塞
            serverSocketChannel.configureBlocking(false);
            // 构建一个选择器，将channel注册进去
            Selector selector = Selector.open();
            serverSocketChannel.register(selector,SelectionKey.OP_ACCEPT);
            SelectionKey selectionKey = serverSocketChannel.register(selector, 0, serverSocketChannel);
//            selectionKey.interestOps()
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
